package com.yzl.springboot.springboot.service.impl;

import com.yzl.springboot.springboot.domain.User;
import com.yzl.springboot.springboot.mapper.UserMapper;
import com.yzl.springboot.springboot.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.sound.midi.Soundbank;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

/**
 * @Title: UserServiceImpl
 * @Author: 姚志立
 * @Description:
 * @Date: 2020/5/24 9:46
 * @Version: 1.0
 */
@Service
public class UserServiceImpl implements UserService {
    public static Map<String,User>sessionMap=new HashMap<>();
    @Autowired
    UserMapper userMapper;
    @Override
    public String login(String username, String pwd) {
        User user = userMapper.login(username, pwd);
        if(user==null){
            return null;
        }else {
            String token = UUID.randomUUID().toString();
            System.out.println(token);
            sessionMap.put(token, user);
            return token;
        }
    }

    @Override
    public List<User> listUser() {
        return userMapper.listUser();
    }
}
